This page last changed on Jul 17, 2005 by aperepel.

The following sample code and spring config fragements together with examples on page Using Spring as a Component Factory, will help illustrate how Ejb can be exposed as Mule components via Spring container.

Code your business interface class

Using business delegate pattern to extend those business methods on Ejb client class that will be called by Mule UMO.

public interface KitchenService extends KitchenServiceEjbClient{

   public void submitOrder(Order order);
}

Setting up Spring

<bean id="kitchenService" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
    <property name="jndiEnvironment">
	<props>
	    <prop key="java.naming.factory.initial">${InitialContextFactoryClassName}</prop>
	    <prop key="java.naming.provider.url">${ProviderUrl}</prop>
	    <prop key="java.naming.security.principal">${Uid}</prop>
	    <prop key="java.naming.security.credentials">${Password}</prop>			
	</props>
    </property>

    <property name="jndiName">
        <value>kitchenService</value>
    </property>        

    <property name="businessInterface">
        <value>com.foo.KitchenService</value>
    </property>
</bean>

<bean id="restaurantWaiter" singleton="false" class="com.foo.RestaurantWaiter">
    <property name="kitchenService">
        <ref local="kitchenService"/>
    </property>
</bean>
Spring 1.2.x

Starting from Spring 1.2, you can use a simpler form for property configuration. See Section 3.3.3.7 in Spring Reference Documentation for details. The above config would look like this:

<bean>
    <!-- JNDI config omitted -->
    ...
    <property name="jndiName" value="kitchenService"/
    <property name="businessInterface" value="com.foo.KitchenService"/>
</bean>

<bean id="restaurantWaiter" singleton="false" class="com.foo.RestaurantWaiter">
    <property name="kitchenService" ref="kitchenService"/>
</bean>
Document generated by Confluence on Nov 27, 2006 10:27